package com.study.compose.beta.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.study.compose.beta.R

@Composable
fun LazyColumnSample() {
    val data = mutableListOf<Int>()
    for (i in 0..100) {
        data.add(i)
    }
    LazyColumn(
        Modifier
            .padding(horizontal = 15.dp)
            .fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        //添加item
        items(count = data.size) { index ->
            if (index % 2 == 0) {
                Text(
                    text = "item$index",
                    Modifier.padding(top = 15.dp, bottom = 15.dp)
                )
            } else {
                Image(
                    painter = painterResource(id = R.mipmap.icon_android),
                    contentDescription = ""
                )
            }
        }
    }
}